import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ButtonPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Button"),
      ),
      body: Column(
        children: [
          RaisedButton(child: Text("RaisedButton"), onPressed: () {}),
          RaisedButton.icon(
              onPressed: () {}, icon: Icon(Icons.send), label: Text("发送")),
          TextButton(onPressed: () {}, child: Text("FlatButton")),
          TextButton.icon(
              onPressed: () {}, icon: Icon(Icons.info), label: Text("详情")),
          OutlineButton(
            onPressed: () {},
            child: Text("OutlineButton"),
          ),
          OutlineButton.icon(
              onPressed: () {}, icon: Icon(Icons.add), label: Text("添加")),
          IconButton(icon: Icon(Icons.thumb_up), onPressed: () {}),
          TextButton(
            onPressed: () {},
            child: Text("Submit TextButton"),
            style: ButtonStyle(
              textStyle: MaterialStateProperty.all(
                  TextStyle(fontSize: 18, color: Colors.red)),
              foregroundColor: MaterialStateProperty.resolveWith((states) {
                if (states.contains(MaterialState.focused) &&
                    !states.contains(MaterialState.pressed)) {
                  //获取焦点时的颜色
                  return Colors.blue;
                } else if (states.contains(MaterialState.pressed)) {
                  //按下时的颜色
                  return Colors.deepPurple;
                }
                //默认状态使用灰色
                return Colors.grey;
              }),
              backgroundColor: MaterialStateProperty.resolveWith((states) {
                if (states.contains(MaterialState.pressed)) {
                  return Colors.blue[200];
                }
                //默认不使用背景颜色
                return null;
              }),
              //设置水波纹颜色
              overlayColor: MaterialStateProperty.all(Colors.yellow),
              //设置阴影  不适用于这里的TextButton
              elevation: MaterialStateProperty.all(0),
              //设置按钮内边距
              padding: MaterialStateProperty.all(EdgeInsets.all(10)),
              //设置按钮的大小
              minimumSize: MaterialStateProperty.all(Size(200, 100)),
//设置边框
              side: MaterialStateProperty.all(
                  BorderSide(color: Colors.grey, width: 1)),
              //外边框装饰 会覆盖 side 配置的样式
              shape: MaterialStateProperty.all(StadiumBorder()),
            ),

            // color: Colors.blue,
            // color: Color(0x000000),
            // highlightColor: Colors.blue[700],
            // // colorBrightness: Brightness.dark,
            // colorBrightness: Brightness.light,
            // splashColor: Colors.grey,
            // shape:
            //     RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
          ),
          RaisedButton(
            onPressed: () {},
            elevation: 2,
            child: Text("Submit"),
            color: Colors.blue,
            // color: Color(0x000000),
            highlightColor: Colors.blue[700],
            colorBrightness: Brightness.dark,
            // colorBrightness: Brightness.light,
            splashColor: Colors.grey,
            shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
          )
        ],
      ),
    );
  }
}
